home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.2 / Video Toaster v4.2.iso / arexx / modeler / pathtolwmotion.lwm < prev    next >
Text File  |  1993-12-13  |  2KB  |  84 lines

  1. /* CMD: Path to Motion
  2.  * Convert Path in layer to LW Motion file.  All points in layer are used,
  3.  * in the order they were created (??)
  4.  * By Arnie Cachelin © 1993 NewTek Inc.
  5.  */
  6.  
  7. NUMERIC DIGITS 6
  8. call addlib "LWModelerARexx.port", 0
  9. call addlib "rexxsupport.library", 0, -30, 0
  10. signal on error
  11. signal on syntax
  12. sysnam = 'Path to Motion '
  13.  
  14. call req_begin sysnam
  15. id_mes  = req_addcontrol("Convert path in",'T',"current layer to LW Motion file")
  16. id_frames  = req_addcontrol("Frames", 'n')
  17. id_skip1 = req_addcontrol("Skip First Point", 'b')
  18. id_skipn = req_addcontrol("Skip Last Point", 'b')
  19. call req_setval id_frames, 60
  20. if (~req_post()) then do
  21.     call req_end
  22.     exit
  23. end
  24.  
  25. frames   = req_getval(id_frames) % 1
  26. skip1= req_getval(id_skip1)
  27. skipn= req_getval(id_skipn)
  28.  
  29. call req_end
  30.  
  31. File.name=getfilename("-- Save Envelope --","Motions")
  32. if File.name ="(none)" then exit
  33.  
  34. h=0; p=0; b=0
  35. xsc=1; ysc=1; zsc=1
  36. File.type="LWMO"
  37. n = xfrm_begin()
  38.   if (n-skip1-skipn)>frames then frames=n-skip1-skip2
  39.   Keys=n-skip1-skipn
  40.   KeySpacing=(Frames/Keys)%1+1
  41.   call WriteHeader(mot,keys)
  42.   do i=1+skip1 to n-skipn
  43.     parse value xfrm_getpos(i) with x y z .
  44.     k=(i-1-skip1)*keyspacing
  45.     call WriteKey(mot,k,0)
  46.     end
  47. call xfrm_end
  48. call close mot
  49. call notify(1,'!Created Motion File: 'File.name)
  50. exit
  51.  
  52. WriteKey:  PROCEDURE  EXPOSE x y z h p b xsc ysc zsc
  53.   arg MotFile, frame, lin
  54.   channels=x y z h p b xsc ysc zsc
  55.   spline=frame lin "0.0 0.0 0.0"
  56.   say channels spline
  57.   call writeln(MotFile,channels)
  58.   call writeln(MotFile,spline)
  59.   return frame
  60.  
  61. WriteHeader: PROCEDURE EXPOSE File.
  62.   arg MotFile, Keys
  63.   if open(MotFile,File.name,'W') then do
  64.     call writeln(MotFile,File.type)
  65.     call writeln(MotFile,"1") /* magic # */
  66.     call writeln(MotFile,"9") /* Channels */
  67.     call writeln(MotFile,Keys)
  68.   end
  69.   else do
  70.     Bummer("Can't open Motion file : "File.name)
  71.   end
  72.   return 1
  73.  
  74. Bummer:
  75.  ARG etxt
  76.     t=Notify(1,'!Rexx Script Error','@'ETxt)
  77.  exit
  78.  
  79. syntax:
  80. error:
  81.   call end_all
  82.     t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  83.     exit
  84.